{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "bd3dc8fb",
   "metadata": {},
   "source": [
    "# Web服务API简介\n",
    "* 高德Web服务API向开发者提供HTTP接口，开发者可通过这些接口使用各类型的地理数据服务，返回结果支持JSON和XML格式。Web服务API对所有用户开放。使用本组服务之前，需要申请应用Key。不同类型用户可获取不同的数据访问能力。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "60f93026",
   "metadata": {},
   "source": [
    "# 地理/逆地理编码\n",
    "* 结构化地址:\n",
    "> 首先，地址肯定是一串字符，内含国家、省份、城市、区县、城镇、乡村、街道、门牌号码、屋邨、大厦等建筑物名称。按照由大区域名称到小区域名称组合在一起的字符。一个有效的地址应该是独一无二的。注意：针对大陆、港、澳地区的地理编码转换时可以将国家信息选择性的忽略，但省、市、城镇等级别的地址构成是不能忽略的。暂时不支持返回台湾省的详细地址信息。\n",
    "\n",
    "* 结构化地址<--->经纬度\n",
    "> 地理编码/逆地理编码 API 是通过 HTTP/HTTPS 协议访问远程服务的接口，提供结构化地址与经纬度之间的相互转化的能力"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7c573ad6",
   "metadata": {},
   "source": [
    "## 地理编码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "dddaf84c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1. 调用requests模块（打开一个Google Chrome 浏览器）\n",
    "import requests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e4313d4e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 2. 请求方法：GET\n",
    "# 3. 请求的地理编码URL地址：https://restapi.amap.com/v3/geocode/geo?parameters\n",
    "geo_url = \"https://restapi.amap.com/v3/geocode/geo?parameters\"\n",
    "\n",
    "# 4. 请求的参数（payload）\n",
    "payload = {\n",
    "    \"key\":\"751cc256307b680656dd4f76d950ab80\",\n",
    "    \"address\":\"广东省广州市从化区广州南方学院\"\n",
    "}\n",
    "\n",
    "# 5. 发起请求\n",
    "r = requests.get(url=geo_url, params=payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a6a8543b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ed0faecf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'count': '1',\n",
       " 'geocodes': [{'formatted_address': '广东省广州市从化区温泉镇中心大学南方学院',\n",
       "   'country': '中国',\n",
       "   'province': '广东省',\n",
       "   'citycode': '020',\n",
       "   'city': '广州市',\n",
       "   'district': '从化区',\n",
       "   'township': [],\n",
       "   'neighborhood': {'name': [], 'type': []},\n",
       "   'building': {'name': [], 'type': []},\n",
       "   'adcode': '440117',\n",
       "   'street': [],\n",
       "   'number': [],\n",
       "   'location': '113.678280,23.628439',\n",
       "   'level': '兴趣点'}]}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "864c3b28",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'113.678280,23.628439'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_location = r.json()['geocodes'][0]['location']\n",
    "广州南方学院_location"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fe6c5f29",
   "metadata": {},
   "source": [
    "## 逆地理编码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "1d448d6e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 2. 请求方法：GET\n",
    "# 3. 请求的地理编码URL地址：https://restapi.amap.com/v3/geocode/regeo?parameters\n",
    "regeo_url = \"https://restapi.amap.com/v3/geocode/regeo?parameters\"\n",
    "\n",
    "# 4. 请求的参数（payload）\n",
    "payload = {\n",
    "    \"key\":\"751cc256307b680656dd4f76d950ab80\",\n",
    "    \"location\":\"113.678280,23.628439\",\n",
    "    \"extensions\":\"all\",  # 返回信息设置为可以选择的全部信息\n",
    "    \"poitype\":\"true\"     # 开启附近搜索POI\n",
    "}\n",
    "\n",
    "# 5. 发起请求\n",
    "r = requests.get(url=regeo_url, params=payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "7313ba99",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "ca5f1776",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'regeocode': {'formatted_address': '广东省广州市从化区温泉镇博学路广州南方学院',\n",
       "  'addressComponent': {'country': '中国',\n",
       "   'province': '广东省',\n",
       "   'city': '广州市',\n",
       "   'citycode': '020',\n",
       "   'district': '从化区',\n",
       "   'adcode': '440117',\n",
       "   'township': '温泉镇',\n",
       "   'towncode': '440117100000',\n",
       "   'neighborhood': {'name': [], 'type': []},\n",
       "   'building': {'name': [], 'type': []},\n",
       "   'streetNumber': {'street': '博学路',\n",
       "    'number': '24号',\n",
       "    'location': '113.677267,23.629149',\n",
       "    'direction': '西北',\n",
       "    'distance': '129.943'},\n",
       "   'businessAreas': [[]]},\n",
       "  'pois': [{'id': 'B00140MR9A',\n",
       "    'name': '广州南方学院',\n",
       "    'type': '科教文化服务;学校;高等院校',\n",
       "    'tel': '020-87828988;020-61787331',\n",
       "    'direction': '北',\n",
       "    'distance': '470.792',\n",
       "    'location': '113.679257,23.632577',\n",
       "    'address': '温泉大道882号',\n",
       "    'poiweight': '0.450402',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFG4TAF2',\n",
       "    'name': '广州南方公寓',\n",
       "    'type': '商务住宅;商务住宅相关;商务住宅相关',\n",
       "    'tel': '13622768437',\n",
       "    'direction': '东南',\n",
       "    'distance': '102.617',\n",
       "    'location': '113.678983,23.627778',\n",
       "    'address': '温泉镇乌土村松浪队5号(近博学路)',\n",
       "    'poiweight': '0.237309',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0H6FA18J5',\n",
       "    'name': '保利半山花园',\n",
       "    'type': '商务住宅;住宅区;住宅区',\n",
       "    'tel': [],\n",
       "    'direction': '东南',\n",
       "    'distance': '139.054',\n",
       "    'location': '113.679358,23.627672',\n",
       "    'address': '从莞深高速(广州南方学院南侧)',\n",
       "    'poiweight': '0.223065',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B00140TWHT',\n",
       "    'name': '教工住宅1号',\n",
       "    'type': '商务住宅;住宅区;住宅小区',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '222.658',\n",
       "    'location': '113.678490,23.630432',\n",
       "    'address': '笃行路2',\n",
       "    'poiweight': '0.157653',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFHRJDM9',\n",
       "    'name': '中南公寓',\n",
       "    'type': '商务住宅;住宅区;住宅小区',\n",
       "    'tel': '13711245345',\n",
       "    'direction': '东南',\n",
       "    'distance': '231.223',\n",
       "    'location': '113.680340,23.627566',\n",
       "    'address': '中大南方学院南门1号',\n",
       "    'poiweight': '0.256152',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD588HJ',\n",
       "    'name': '广州南方学院教学楼4号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '242.901',\n",
       "    'location': '113.677460,23.630490',\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFHZH0IK',\n",
       "    'name': '地下铁',\n",
       "    'type': '餐饮服务;冷饮店;冷饮店',\n",
       "    'tel': [],\n",
       "    'direction': '西北',\n",
       "    'distance': '74.1376',\n",
       "    'location': '113.677941,23.629029',\n",
       "    'address': '博学路广州南方学院综合楼内',\n",
       "    'poiweight': '0.17934',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU76L2',\n",
       "    'name': '广州南方学院2号实验楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '280.003',\n",
       "    'location': '113.678211,23.630956',\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFKP838K',\n",
       "    'name': '教学楼3号(外国语学院)',\n",
       "    'type': '科教文化服务;学校;高等院校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '298.093',\n",
       "    'location': '113.677247,23.630947',\n",
       "    'address': '博学路25',\n",
       "    'poiweight': '0.191742',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFKSF1FI',\n",
       "    'name': '香辣螺蛳粉',\n",
       "    'type': '餐饮服务;餐饮相关场所;餐饮相关',\n",
       "    'tel': '17820061022',\n",
       "    'direction': '西',\n",
       "    'distance': '209.206',\n",
       "    'location': '113.676231,23.628565',\n",
       "    'address': '广州南方学院西4123',\n",
       "    'poiweight': '0.209252',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU8NLD',\n",
       "    'name': '广州南方学院1号实验楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '326.007',\n",
       "    'location': '113.678215,23.631370',\n",
       "    'address': '博学路附近',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFLF90I2',\n",
       "    'name': '煌上煌酱鸭(南方学院店)',\n",
       "    'type': '餐饮服务;快餐厅;快餐厅',\n",
       "    'tel': '13712317721',\n",
       "    'direction': '东北',\n",
       "    'distance': '256.772',\n",
       "    'location': '113.679965,23.630156',\n",
       "    'address': '笃行路20、22、24号广州南方学院商业中心1层1F015',\n",
       "    'poiweight': '0.209448',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD58UTU',\n",
       "    'name': '广州南方学院2号教学楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '西北',\n",
       "    'distance': '346.352',\n",
       "    'location': '113.677060,23.631346',\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.191229',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0H25SMRKP',\n",
       "    'name': '广州南方学院大礼堂',\n",
       "    'type': '科教文化服务;会展中心;会展中心',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '386.65',\n",
       "    'location': '113.680076,23.631502',\n",
       "    'address': '温泉大道882号',\n",
       "    'poiweight': '0.261624',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU92JD',\n",
       "    'name': '广州南方学院教学楼1号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '391.548',\n",
       "    'location': '113.677077,23.631783',\n",
       "    'address': '博学路19号',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD592BJ',\n",
       "    'name': '广州南方学院综合楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '392.731',\n",
       "    'location': '113.680117,23.631544',\n",
       "    'address': '温泉大道886号广州南方学院内',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFKP81F0',\n",
       "    'name': '教学楼1号(文学与传媒学院)',\n",
       "    'type': '科教文化服务;科教文化场所;科教文化场所',\n",
       "    'tel': [],\n",
       "    'direction': '西北',\n",
       "    'distance': '393.93',\n",
       "    'location': '113.676866,23.631736',\n",
       "    'address': '博学路19号附近',\n",
       "    'poiweight': '0.191742',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFLBEOND',\n",
       "    'name': '聚贤楼10号',\n",
       "    'type': '商务住宅;住宅区;宿舍',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '418.51',\n",
       "    'location': '113.681253,23.631036',\n",
       "    'address': '从莞深高速(广州南方学院)',\n",
       "    'poiweight': '0.190963',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFH6K3U9',\n",
       "    'name': '广州中大南方招待所',\n",
       "    'type': '住宿服务;住宿服务相关;住宿服务相关',\n",
       "    'tel': '020-61787222',\n",
       "    'direction': '西北',\n",
       "    'distance': '378.102',\n",
       "    'location': '113.676330,23.631332',\n",
       "    'address': '温泉镇温泉大道882号广州南方学院H7栋1-5层',\n",
       "    'poiweight': '0.254885',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD58NF8',\n",
       "    'name': '广州南方学院达人书院',\n",
       "    'type': '科教文化服务;科教文化场所;科教文化场所',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '446.366',\n",
       "    'location': '113.679041,23.632392',\n",
       "    'address': '温泉大道882号广州南方学院新综合楼2层',\n",
       "    'poiweight': '0.191229',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFKUVYWV',\n",
       "    'name': '广州和风庭阿七度假别墅',\n",
       "    'type': '住宿服务;住宿服务相关;住宿服务相关',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '424.35',\n",
       "    'location': '113.681736,23.630569',\n",
       "    'address': '保利桃花源',\n",
       "    'poiweight': '0.273168',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU99RM',\n",
       "    'name': '广州南方学院图书馆',\n",
       "    'type': '科教文化服务;图书馆;图书馆',\n",
       "    'tel': '020-61787368;020-61787371',\n",
       "    'direction': '北',\n",
       "    'distance': '489.331',\n",
       "    'location': '113.679177,23.632762',\n",
       "    'address': '温泉大道882号广州南方学院内',\n",
       "    'poiweight': '0.257947',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU92JC',\n",
       "    'name': '广州南方学院4号实验楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '498.883',\n",
       "    'location': '113.679963,23.632652',\n",
       "    'address': '博学路附近',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFL7C054',\n",
       "    'name': '广州U优森特酒店',\n",
       "    'type': '住宿服务;住宿服务相关;住宿服务相关',\n",
       "    'tel': '15813395296',\n",
       "    'direction': '北',\n",
       "    'distance': '464.819',\n",
       "    'location': '113.679226,23.632528',\n",
       "    'address': '温泉镇博学路882号(广州南方学院商业中心1层)',\n",
       "    'poiweight': '0.317505',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0FFG8CSEK',\n",
       "    'name': 'L5员工宿舍',\n",
       "    'type': '商务住宅;住宅区;宿舍',\n",
       "    'tel': [],\n",
       "    'direction': '东北',\n",
       "    'distance': '554.129',\n",
       "    'location': '113.682583,23.631487',\n",
       "    'address': '从莞深高速(广州南方学院)',\n",
       "    'poiweight': '0.185371',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD58FR2',\n",
       "    'name': '广州南方学院教学楼9号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '532.163',\n",
       "    'location': '113.679747,23.633032',\n",
       "    'address': '广州南方学院',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HG5Z9JNK',\n",
       "    'name': '广州南方学院教学楼7号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '544.868',\n",
       "    'location': '113.678600,23.633330',\n",
       "    'address': '博学路',\n",
       "    'poiweight': '0.221553',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGD599JM',\n",
       "    'name': '广州南方学院第11教学楼',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '556.036',\n",
       "    'location': '113.680037,23.633173',\n",
       "    'address': '温泉大道882号广州南方学院',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0GUJYPEG2',\n",
       "    'name': '怒烤烤串(从化店)',\n",
       "    'type': '餐饮服务;中餐厅;特色/地方风味餐厅',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '510.112',\n",
       "    'location': '113.677160,23.632910',\n",
       "    'address': '温泉大道882号广州南方学院内博学路6号之3',\n",
       "    'poiweight': '0.216026',\n",
       "    'businessarea': []},\n",
       "   {'id': 'B0HGDU6Z41',\n",
       "    'name': '广州南方学院教学楼6号',\n",
       "    'type': '科教文化服务;学校;学校',\n",
       "    'tel': [],\n",
       "    'direction': '北',\n",
       "    'distance': '586.331',\n",
       "    'location': '113.678424,23.633710',\n",
       "    'address': '温泉大道882',\n",
       "    'poiweight': '0.221662',\n",
       "    'businessarea': []}],\n",
       "  'roads': [{'id': '020F49F0050461206',\n",
       "    'name': '博学路',\n",
       "    'direction': '北',\n",
       "    'distance': '7.63232',\n",
       "    'location': '113.678,23.6284'},\n",
       "   {'id': '020F49F0050462229',\n",
       "    'name': '老虎形街',\n",
       "    'direction': '北',\n",
       "    'distance': '445.159',\n",
       "    'location': '113.679,23.6245'},\n",
       "   {'id': '020F49F0050462451',\n",
       "    'name': '中山路',\n",
       "    'direction': '南',\n",
       "    'distance': '708.299',\n",
       "    'location': '113.677,23.6347'}],\n",
       "  'roadinters': [{'direction': '南',\n",
       "    'distance': '708.299',\n",
       "    'location': '113.676794,23.634661',\n",
       "    'first_id': '020F49F0050461206',\n",
       "    'first_name': '博学路',\n",
       "    'second_id': '020F49F0050462451',\n",
       "    'second_name': '中山路'}],\n",
       "  'aois': [{'id': 'B00140MR9A',\n",
       "    'name': '广州南方学院',\n",
       "    'adcode': '440117',\n",
       "    'location': '113.679257,23.632577',\n",
       "    'area': '528560.656426',\n",
       "    'distance': '0',\n",
       "    'type': '141201'}]}}"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "57fc8743",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "50e3f02d",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid character '、' (U+3001) (2174757197.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[0;36m  File \u001b[0;32m\"/var/folders/c2/_wn0sq3s66v1nhs_127pw_sm0000gn/T/ipykernel_3470/2174757197.py\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m    天选之饭--周边--(中餐厅、外国餐厅、快餐厅、休闲餐厅)\u001b[0m\n\u001b[0m                  ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid character '、' (U+3001)\n"
     ]
    }
   ],
   "source": [
    "天选之饭--周边--(中餐厅、外国餐厅、快餐厅、休闲餐厅)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "01c1a3d1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>20</th>\n",
       "      <th>21</th>\n",
       "      <th>22</th>\n",
       "      <th>23</th>\n",
       "      <th>24</th>\n",
       "      <th>25</th>\n",
       "      <th>26</th>\n",
       "      <th>27</th>\n",
       "      <th>28</th>\n",
       "      <th>29</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>id</th>\n",
       "      <td>B00140MR9A</td>\n",
       "      <td>B0FFG4TAF2</td>\n",
       "      <td>B0H6FA18J5</td>\n",
       "      <td>B00140TWHT</td>\n",
       "      <td>B0FFHRJDM9</td>\n",
       "      <td>B0HGD588HJ</td>\n",
       "      <td>B0FFHZH0IK</td>\n",
       "      <td>B0HGDU76L2</td>\n",
       "      <td>B0FFKP838K</td>\n",
       "      <td>B0FFKSF1FI</td>\n",
       "      <td>...</td>\n",
       "      <td>B0FFKUVYWV</td>\n",
       "      <td>B0HGDU99RM</td>\n",
       "      <td>B0HGDU92JC</td>\n",
       "      <td>B0FFL7C054</td>\n",
       "      <td>B0FFG8CSEK</td>\n",
       "      <td>B0HGD58FR2</td>\n",
       "      <td>B0HG5Z9JNK</td>\n",
       "      <td>B0HGD599JM</td>\n",
       "      <td>B0GUJYPEG2</td>\n",
       "      <td>B0HGDU6Z41</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>name</th>\n",
       "      <td>广州南方学院</td>\n",
       "      <td>广州南方公寓</td>\n",
       "      <td>保利半山花园</td>\n",
       "      <td>教工住宅1号</td>\n",
       "      <td>中南公寓</td>\n",
       "      <td>广州南方学院教学楼4号</td>\n",
       "      <td>地下铁</td>\n",
       "      <td>广州南方学院2号实验楼</td>\n",
       "      <td>教学楼3号(外国语学院)</td>\n",
       "      <td>香辣螺蛳粉</td>\n",
       "      <td>...</td>\n",
       "      <td>广州和风庭阿七度假别墅</td>\n",
       "      <td>广州南方学院图书馆</td>\n",
       "      <td>广州南方学院4号实验楼</td>\n",
       "      <td>广州U优森特酒店</td>\n",
       "      <td>L5员工宿舍</td>\n",
       "      <td>广州南方学院教学楼9号</td>\n",
       "      <td>广州南方学院教学楼7号</td>\n",
       "      <td>广州南方学院第11教学楼</td>\n",
       "      <td>怒烤烤串(从化店)</td>\n",
       "      <td>广州南方学院教学楼6号</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>type</th>\n",
       "      <td>科教文化服务;学校;高等院校</td>\n",
       "      <td>商务住宅;商务住宅相关;商务住宅相关</td>\n",
       "      <td>商务住宅;住宅区;住宅区</td>\n",
       "      <td>商务住宅;住宅区;住宅小区</td>\n",
       "      <td>商务住宅;住宅区;住宅小区</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>餐饮服务;冷饮店;冷饮店</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;学校;高等院校</td>\n",
       "      <td>餐饮服务;餐饮相关场所;餐饮相关</td>\n",
       "      <td>...</td>\n",
       "      <td>住宿服务;住宿服务相关;住宿服务相关</td>\n",
       "      <td>科教文化服务;图书馆;图书馆</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>住宿服务;住宿服务相关;住宿服务相关</td>\n",
       "      <td>商务住宅;住宅区;宿舍</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "      <td>餐饮服务;中餐厅;特色/地方风味餐厅</td>\n",
       "      <td>科教文化服务;学校;学校</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>tel</th>\n",
       "      <td>020-87828988;020-61787331</td>\n",
       "      <td>13622768437</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>13711245345</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>17820061022</td>\n",
       "      <td>...</td>\n",
       "      <td>[]</td>\n",
       "      <td>020-61787368;020-61787371</td>\n",
       "      <td>[]</td>\n",
       "      <td>15813395296</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>direction</th>\n",
       "      <td>北</td>\n",
       "      <td>东南</td>\n",
       "      <td>东南</td>\n",
       "      <td>北</td>\n",
       "      <td>东南</td>\n",
       "      <td>北</td>\n",
       "      <td>西北</td>\n",
       "      <td>北</td>\n",
       "      <td>北</td>\n",
       "      <td>西</td>\n",
       "      <td>...</td>\n",
       "      <td>东北</td>\n",
       "      <td>北</td>\n",
       "      <td>北</td>\n",
       "      <td>北</td>\n",
       "      <td>东北</td>\n",
       "      <td>北</td>\n",
       "      <td>北</td>\n",
       "      <td>北</td>\n",
       "      <td>北</td>\n",
       "      <td>北</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>distance</th>\n",
       "      <td>470.792</td>\n",
       "      <td>102.617</td>\n",
       "      <td>139.054</td>\n",
       "      <td>222.658</td>\n",
       "      <td>231.223</td>\n",
       "      <td>242.901</td>\n",
       "      <td>74.1376</td>\n",
       "      <td>280.003</td>\n",
       "      <td>298.093</td>\n",
       "      <td>209.206</td>\n",
       "      <td>...</td>\n",
       "      <td>424.35</td>\n",
       "      <td>489.331</td>\n",
       "      <td>498.883</td>\n",
       "      <td>464.819</td>\n",
       "      <td>554.129</td>\n",
       "      <td>532.163</td>\n",
       "      <td>544.868</td>\n",
       "      <td>556.036</td>\n",
       "      <td>510.112</td>\n",
       "      <td>586.331</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>location</th>\n",
       "      <td>113.679257,23.632577</td>\n",
       "      <td>113.678983,23.627778</td>\n",
       "      <td>113.679358,23.627672</td>\n",
       "      <td>113.678490,23.630432</td>\n",
       "      <td>113.680340,23.627566</td>\n",
       "      <td>113.677460,23.630490</td>\n",
       "      <td>113.677941,23.629029</td>\n",
       "      <td>113.678211,23.630956</td>\n",
       "      <td>113.677247,23.630947</td>\n",
       "      <td>113.676231,23.628565</td>\n",
       "      <td>...</td>\n",
       "      <td>113.681736,23.630569</td>\n",
       "      <td>113.679177,23.632762</td>\n",
       "      <td>113.679963,23.632652</td>\n",
       "      <td>113.679226,23.632528</td>\n",
       "      <td>113.682583,23.631487</td>\n",
       "      <td>113.679747,23.633032</td>\n",
       "      <td>113.678600,23.633330</td>\n",
       "      <td>113.680037,23.633173</td>\n",
       "      <td>113.677160,23.632910</td>\n",
       "      <td>113.678424,23.633710</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>address</th>\n",
       "      <td>温泉大道882号</td>\n",
       "      <td>温泉镇乌土村松浪队5号(近博学路)</td>\n",
       "      <td>从莞深高速(广州南方学院南侧)</td>\n",
       "      <td>笃行路2</td>\n",
       "      <td>中大南方学院南门1号</td>\n",
       "      <td>博学路</td>\n",
       "      <td>博学路广州南方学院综合楼内</td>\n",
       "      <td>博学路</td>\n",
       "      <td>博学路25</td>\n",
       "      <td>广州南方学院西4123</td>\n",
       "      <td>...</td>\n",
       "      <td>保利桃花源</td>\n",
       "      <td>温泉大道882号广州南方学院内</td>\n",
       "      <td>博学路附近</td>\n",
       "      <td>温泉镇博学路882号(广州南方学院商业中心1层)</td>\n",
       "      <td>从莞深高速(广州南方学院)</td>\n",
       "      <td>广州南方学院</td>\n",
       "      <td>博学路</td>\n",
       "      <td>温泉大道882号广州南方学院</td>\n",
       "      <td>温泉大道882号广州南方学院内博学路6号之3</td>\n",
       "      <td>温泉大道882</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>poiweight</th>\n",
       "      <td>0.450402</td>\n",
       "      <td>0.237309</td>\n",
       "      <td>0.223065</td>\n",
       "      <td>0.157653</td>\n",
       "      <td>0.256152</td>\n",
       "      <td>0.221662</td>\n",
       "      <td>0.17934</td>\n",
       "      <td>0.221662</td>\n",
       "      <td>0.191742</td>\n",
       "      <td>0.209252</td>\n",
       "      <td>...</td>\n",
       "      <td>0.273168</td>\n",
       "      <td>0.257947</td>\n",
       "      <td>0.221662</td>\n",
       "      <td>0.317505</td>\n",
       "      <td>0.185371</td>\n",
       "      <td>0.221662</td>\n",
       "      <td>0.221553</td>\n",
       "      <td>0.221662</td>\n",
       "      <td>0.216026</td>\n",
       "      <td>0.221662</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>businessarea</th>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>...</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 30 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                     0                     1   \\\n",
       "id                           B00140MR9A            B0FFG4TAF2   \n",
       "name                             广州南方学院                广州南方公寓   \n",
       "type                     科教文化服务;学校;高等院校    商务住宅;商务住宅相关;商务住宅相关   \n",
       "tel           020-87828988;020-61787331           13622768437   \n",
       "direction                             北                    东南   \n",
       "distance                        470.792               102.617   \n",
       "location           113.679257,23.632577  113.678983,23.627778   \n",
       "address                        温泉大道882号     温泉镇乌土村松浪队5号(近博学路)   \n",
       "poiweight                      0.450402              0.237309   \n",
       "businessarea                         []                    []   \n",
       "\n",
       "                                2                     3   \\\n",
       "id                      B0H6FA18J5            B00140TWHT   \n",
       "name                        保利半山花园                教工住宅1号   \n",
       "type                  商务住宅;住宅区;住宅区         商务住宅;住宅区;住宅小区   \n",
       "tel                             []                    []   \n",
       "direction                       东南                     北   \n",
       "distance                   139.054               222.658   \n",
       "location      113.679358,23.627672  113.678490,23.630432   \n",
       "address            从莞深高速(广州南方学院南侧)                  笃行路2   \n",
       "poiweight                 0.223065              0.157653   \n",
       "businessarea                    []                    []   \n",
       "\n",
       "                                4                     5   \\\n",
       "id                      B0FFHRJDM9            B0HGD588HJ   \n",
       "name                          中南公寓           广州南方学院教学楼4号   \n",
       "type                 商务住宅;住宅区;住宅小区          科教文化服务;学校;学校   \n",
       "tel                    13711245345                    []   \n",
       "direction                       东南                     北   \n",
       "distance                   231.223               242.901   \n",
       "location      113.680340,23.627566  113.677460,23.630490   \n",
       "address                 中大南方学院南门1号                   博学路   \n",
       "poiweight                 0.256152              0.221662   \n",
       "businessarea                    []                    []   \n",
       "\n",
       "                                6                     7   \\\n",
       "id                      B0FFHZH0IK            B0HGDU76L2   \n",
       "name                           地下铁           广州南方学院2号实验楼   \n",
       "type                  餐饮服务;冷饮店;冷饮店          科教文化服务;学校;学校   \n",
       "tel                             []                    []   \n",
       "direction                       西北                     北   \n",
       "distance                   74.1376               280.003   \n",
       "location      113.677941,23.629029  113.678211,23.630956   \n",
       "address              博学路广州南方学院综合楼内                   博学路   \n",
       "poiweight                  0.17934              0.221662   \n",
       "businessarea                    []                    []   \n",
       "\n",
       "                                8                     9   ...  \\\n",
       "id                      B0FFKP838K            B0FFKSF1FI  ...   \n",
       "name                  教学楼3号(外国语学院)                 香辣螺蛳粉  ...   \n",
       "type                科教文化服务;学校;高等院校      餐饮服务;餐饮相关场所;餐饮相关  ...   \n",
       "tel                             []           17820061022  ...   \n",
       "direction                        北                     西  ...   \n",
       "distance                   298.093               209.206  ...   \n",
       "location      113.677247,23.630947  113.676231,23.628565  ...   \n",
       "address                      博学路25           广州南方学院西4123  ...   \n",
       "poiweight                 0.191742              0.209252  ...   \n",
       "businessarea                    []                    []  ...   \n",
       "\n",
       "                                20                         21  \\\n",
       "id                      B0FFKUVYWV                 B0HGDU99RM   \n",
       "name                   广州和风庭阿七度假别墅                  广州南方学院图书馆   \n",
       "type            住宿服务;住宿服务相关;住宿服务相关             科教文化服务;图书馆;图书馆   \n",
       "tel                             []  020-61787368;020-61787371   \n",
       "direction                       东北                          北   \n",
       "distance                    424.35                    489.331   \n",
       "location      113.681736,23.630569       113.679177,23.632762   \n",
       "address                      保利桃花源            温泉大道882号广州南方学院内   \n",
       "poiweight                 0.273168                   0.257947   \n",
       "businessarea                    []                         []   \n",
       "\n",
       "                                22                        23  \\\n",
       "id                      B0HGDU92JC                B0FFL7C054   \n",
       "name                   广州南方学院4号实验楼                  广州U优森特酒店   \n",
       "type                  科教文化服务;学校;学校        住宿服务;住宿服务相关;住宿服务相关   \n",
       "tel                             []               15813395296   \n",
       "direction                        北                         北   \n",
       "distance                   498.883                   464.819   \n",
       "location      113.679963,23.632652      113.679226,23.632528   \n",
       "address                      博学路附近  温泉镇博学路882号(广州南方学院商业中心1层)   \n",
       "poiweight                 0.221662                  0.317505   \n",
       "businessarea                    []                        []   \n",
       "\n",
       "                                24                    25  \\\n",
       "id                      B0FFG8CSEK            B0HGD58FR2   \n",
       "name                        L5员工宿舍           广州南方学院教学楼9号   \n",
       "type                   商务住宅;住宅区;宿舍          科教文化服务;学校;学校   \n",
       "tel                             []                    []   \n",
       "direction                       东北                     北   \n",
       "distance                   554.129               532.163   \n",
       "location      113.682583,23.631487  113.679747,23.633032   \n",
       "address              从莞深高速(广州南方学院)                广州南方学院   \n",
       "poiweight                 0.185371              0.221662   \n",
       "businessarea                    []                    []   \n",
       "\n",
       "                                26                    27  \\\n",
       "id                      B0HG5Z9JNK            B0HGD599JM   \n",
       "name                   广州南方学院教学楼7号          广州南方学院第11教学楼   \n",
       "type                  科教文化服务;学校;学校          科教文化服务;学校;学校   \n",
       "tel                             []                    []   \n",
       "direction                        北                     北   \n",
       "distance                   544.868               556.036   \n",
       "location      113.678600,23.633330  113.680037,23.633173   \n",
       "address                        博学路        温泉大道882号广州南方学院   \n",
       "poiweight                 0.221553              0.221662   \n",
       "businessarea                    []                    []   \n",
       "\n",
       "                                  28                    29  \n",
       "id                        B0GUJYPEG2            B0HGDU6Z41  \n",
       "name                       怒烤烤串(从化店)           广州南方学院教学楼6号  \n",
       "type              餐饮服务;中餐厅;特色/地方风味餐厅          科教文化服务;学校;学校  \n",
       "tel                               []                    []  \n",
       "direction                          北                     北  \n",
       "distance                     510.112               586.331  \n",
       "location        113.677160,23.632910  113.678424,23.633710  \n",
       "address       温泉大道882号广州南方学院内博学路6号之3               温泉大道882  \n",
       "poiweight                   0.216026              0.221662  \n",
       "businessarea                      []                    []  \n",
       "\n",
       "[10 rows x 30 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.json_normalize(r.json()['regeocode']['pois']).T"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "55ecb6c5",
   "metadata": {},
   "source": [
    "## 作业\n",
    "> 1. 尝试搜索POI2.0 接口\n",
    "> 2. 获取中餐厅、西餐厅、快餐厅的信息(图片、内容等)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cd9f70f5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "60fdbc05",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "hide_input": false,
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
